package cn.hls.entity;

import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

import org.codehaus.jackson.annotate.JsonIgnore;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

/**
 * @fileName: ShipOrder.java
 * @package: cn.hls.entity 　
 * @Description: 托运单实体类
 * @author: yinghui.zhang
 * @email: uuhui@163.com
 * @date: 2016年6月10日
 * 
 */
@Entity
@Table(name = "t_shiporder")
@DynamicInsert
@DynamicUpdate
public class ShipOrder extends BaseEntity {
	private static final long serialVersionUID = -8397601822971125935L;
	private Shipper shipper;// 托运方信息
	private Date shipTime;// 托运日期
	private Date beginShipTime;// 托运开始时间
	private Date endShipTime;// 托运结束时间
	private List<ShipOrderSite>shipOrderSendSites;//发货地址列表
	private List<ShipOrderSite>shipOrderReceiveSites;//收货地址列表
	private List<ShipOrderGoods>shipOrderGoods;//货物信息
	private String loadAddress;// 装货地址
	private String unloadAddress;// 卸货地址
	private Date loadGoodsTime;// 装货时间
	private Date unloadGoodsTime;// 卸货时间
	private Car car;// 派车信息
	private Float carryCapacity;//载重量(吨)
	private Long driverId;// 驾驶员编号
	private String driverName;// 驾驶员名称
	private Long escortId;// 押运员编号
	private String escortName;// 押运员名称

	private String remark;// 备注

	private Long companyId;//电子运单的承运企业编号
	@ManyToOne(cascade = CascadeType.REFRESH)
	@NotFound(action = NotFoundAction.IGNORE)
	@JoinColumn(name = "shipper_id")
	public Shipper getShipper() {
		return shipper;
	}

	public void setShipper(Shipper shipper) {
		this.shipper = shipper;
	}

	@Column(name = "ship_time", nullable = false, columnDefinition = "date default sysdate")
	public Date getShipTime() {
		return shipTime;
	}

	public void setShipTime(Date shipTime) {
		this.shipTime = shipTime;
	}

	
	@Transient
	@JsonIgnore
	public List<ShipOrderGoods> getShipOrderGoods() {
		return shipOrderGoods;
	}

	public void setShipOrderGoods(List<ShipOrderGoods> shipOrderGoods) {
		this.shipOrderGoods = shipOrderGoods;
	}
	
	@Transient
	@JsonIgnore
	public List<ShipOrderSite> getShipOrderSendSites() {
		return shipOrderSendSites;
	}

	public void setShipOrderSendSites(List<ShipOrderSite> shipOrderSendSites) {
		this.shipOrderSendSites = shipOrderSendSites;
	}

	@Transient
	@JsonIgnore
	public List<ShipOrderSite> getShipOrderReceiveSites() {
		return shipOrderReceiveSites;
	}

	public void setShipOrderReceiveSites(List<ShipOrderSite> shipOrderReceiveSites) {
		this.shipOrderReceiveSites = shipOrderReceiveSites;
	}

	@Column(name = "load_address", length = 100)
	public String getLoadAddress() {
		return loadAddress;
	}

	public void setLoadAddress(String loadAddress) {
		this.loadAddress = loadAddress;
	}

	@Column(name = "unload_Address")
	public String getUnloadAddress() {
		return unloadAddress;
	}

	public void setUnloadAddress(String unloadAddress) {
		this.unloadAddress = unloadAddress;
	}

	@ManyToOne(cascade = CascadeType.REFRESH)
	@NotFound(action = NotFoundAction.IGNORE)
	@JoinColumn(name = "car_id")
	public Car getCar() {
		return car;
	}

	public void setCar(Car car) {
		this.car = car;
	}
	
	@Column(name="carry_capacity")
	public Float getCarryCapacity() {
		return carryCapacity;
	}

	public void setCarryCapacity(Float carryCapacity) {
		this.carryCapacity = carryCapacity;
	}

	@Column(name="driver_id")
	public Long getDriverId() {
		return driverId;
	}

	public void setDriverId(Long driverId) {
		this.driverId = driverId;
	}

	@Column(name="driver_name",length=16)
	public String getDriverName() {
		return driverName;
	}

	public void setDriverName(String driverName) {
		this.driverName = driverName;
	}

	@Column(name="escort_id")
	public Long getEscortId() {
		return escortId;
	}

	public void setEscortId(Long escortId) {
		this.escortId = escortId;
	}

	@Column(name="escort_name",length=16)
	public String getEscortName() {
		return escortName;
	}

	public void setEscortName(String escortName) {
		this.escortName = escortName;
	}

	@Column(name = "load_goods_time")
	@Temporal(TemporalType.TIMESTAMP)
	public Date getLoadGoodsTime() {
		return loadGoodsTime;
	}

	public void setLoadGoodsTime(Date loadGoodsTime) {
		this.loadGoodsTime = loadGoodsTime;
	}

	@Column(name = "unload_goods_time")
	@Temporal(TemporalType.TIMESTAMP)
	public Date getUnloadGoodsTime() {
		return unloadGoodsTime;
	}

	public void setUnloadGoodsTime(Date unloadGoodsTime) {
		this.unloadGoodsTime = unloadGoodsTime;
	}

	@JsonIgnore
	@Transient
	public Date getBeginShipTime() {
		return beginShipTime;
	}

	public void setBeginShipTime(Date beginShipTime) {
		this.beginShipTime = beginShipTime;
	}

	@JsonIgnore
	@Transient
	public Date getEndShipTime() {
		return endShipTime;
	}

	public void setEndShipTime(Date endShipTime) {
		this.endShipTime = endShipTime;
	}

	@JsonIgnore
	@Column(name = "remark", length = 100)
	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}
	
	@Column(name="company_id")
	public Long getCompanyId() {
		return companyId;
	}

	public void setCompanyId(Long companyId) {
		this.companyId = companyId;
	}
}
